/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "circles")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Circles.findAll", query = "SELECT c FROM Circles c"),
    @NamedQuery(name = "Circles.findByCircleId", query = "SELECT c FROM Circles c WHERE c.circleId = :circleId"),
    @NamedQuery(name = "Circles.findByCircleNAME", query = "SELECT c FROM Circles c WHERE c.circleNAME = :circleNAME"),
    @NamedQuery(name = "Circles.findByType", query = "SELECT c FROM Circles c WHERE c.type = :type")})
public class Circles implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "Circle_Id")
    private Integer circleId;
    @Size(max = 100)
    @Column(name = "Circle_NAME")
    private String circleNAME;
    @Size(max = 50)
    @Column(name = "Type")
    private String type;
    @JoinTable(name = "circle_members", joinColumns = {
        @JoinColumn(name = "Circle_Id", referencedColumnName = "Circle_Id")}, inverseJoinColumns = {
        @JoinColumn(name = "Member_Id", referencedColumnName = "User_Id")})
    @ManyToMany
    private Collection<Users> usersCollection;
    @OneToMany(mappedBy = "circle")
    private Collection<Posts> postsCollection;
    @JoinColumn(name = "Owner_Of_Circle", referencedColumnName = "User_Id")
    @ManyToOne
    private Users ownerOfCircle;

    public Circles() {
    }

    public Circles(Integer circleId) {
        this.circleId = circleId;
    }

    public Integer getCircleId() {
        return circleId;
    }

    public void setCircleId(Integer circleId) {
        this.circleId = circleId;
    }

    public String getCircleNAME() {
        return circleNAME;
    }

    public void setCircleNAME(String circleNAME) {
        this.circleNAME = circleNAME;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlTransient
    public Collection<Users> getUsersCollection() {
        return usersCollection;
    }

    public void setUsersCollection(Collection<Users> usersCollection) {
        this.usersCollection = usersCollection;
    }

    @XmlTransient
    public Collection<Posts> getPostsCollection() {
        return postsCollection;
    }

    public void setPostsCollection(Collection<Posts> postsCollection) {
        this.postsCollection = postsCollection;
    }

    public Users getOwnerOfCircle() {
        return ownerOfCircle;
    }

    public void setOwnerOfCircle(Users ownerOfCircle) {
        this.ownerOfCircle = ownerOfCircle;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (circleId != null ? circleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Circles)) {
            return false;
        }
        Circles other = (Circles) object;
        if ((this.circleId == null && other.circleId != null) || (this.circleId != null && !this.circleId.equals(other.circleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Circles[ circleId=" + circleId + " ]";
    }
    
}
